package 并发编程02.volatile关键字案例;

/**
 * @author idea
 * @data 2018/12/28
 */
public class VolatileSingleton {

    private volatile VolatileSingleton volatileSingleton;

    public VolatileSingleton getVolatileSingleton() {
        if (volatileSingleton == null) {
            synchronized (VolatileSingleton.class) {
                if (volatileSingleton == null) {
                    volatileSingleton = new VolatileSingleton();
                }
            }
        }
        return volatileSingleton;
    }

}
